import React from 'react';
import {Steps,Input,Button,message, Card,Modal} from 'antd';
import NewProjectOne from './NewProjectOne';
import NewProjectTow from './NewProjectTow';
import NewProjectThree from './NewProjectThree';
import NewProjectFive from './NewProjectFive';
import NewProjectFour from './NewProjectFour';
// cv大法
const { Step } = Steps;
const {confirm} = Modal
class NewProject extends React.Component {
    constructor(props) {
        super(props);
        this.state = { 
            current:0,
            userInfo:JSON.parse(sessionStorage.getItem("userInfo"))
         };
    }
    onRef=(ref)=>{
      this.setState({modal:ref})
    }
    next() {        
        if(this.state.modal.saveDatas()){
        const current = this.state.current + 1;
        this.setState({ current });
      }
      }
      submit=()=>{
        this.state.modal.submit()
      }
      prev() {
        const current = this.state.current - 1;
        this.setState({ current });
      }
      
    render() {
        const {current}=this.state  
        const steps = [
            {
              title: '第一步',
              content: '基本信息',
            },
            {
              title: '第二步',
              content: '项目成员',
            },
            {
                title: '第三步',
                content: '附件',
              },
              {
                title: '第四步',
                content: '预算',
              },
              {
                title: '第五步',
                content: '进度安排',
              },
          ];
        return (
            <div>
                      <Card style={{margin:10,width:1000}} bordered={false}>

                 <Steps current={current}>
          {steps.map(item => (
            <Step key={item.title} title={`${item.title}（${item.content}）`} />
          ))}
        </Steps>
        </Card>

        <Card style={{margin:10,width:1000}} bordered={false}>
        {current===0&&<NewProjectOne onRef={this.onRef}/>}
        {current===1&&<NewProjectTow onRef={this.onRef} />}
        {current===2&&<NewProjectThree onRef={this.onRef} />}
        {current===3&&<NewProjectFour onRef={this.onRef} />}
        {current===4&&<NewProjectFive onRef={this.onRef} onCancel={this.props.onCancel} />}
        </Card>
       
        <div className="steps-action" style={{textAlign:'right'}}>
        {current > 0 && (
            <Button style={{ margin: '0 8px' }} onClick={() => this.prev()}>
              上一步
            </Button>
          )}
         
          {current === steps.length - 1 && (
            <Button type="primary" onClick={this.submit}>
              完成
            </Button>
          )}
          {current < steps.length - 1 && (
            <Button type="primary" onClick={() => this.next()}>
              下一步
            </Button>
          )}
        </div>
            </div>
        );
    }
}

export default NewProject;